home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BMUG PD-ROM B4
/
PD-ROM B4.iso
/
Utilities
/
Text and Speech
/
Alpha 5.3
/
Help
/
Alpha Tcl Extensions
< prev
next >
Wrap
Text File
|
1993-01-30
|
17KB
|
319 lines
==============================================================================
= Alpha's Additional Tcl Commands
==============================================================================
In this list of routines, text between '<' and '>' is a placeholder for a
required parameter, text between '[' and ']' is a placeholder for an
optional parameter, and the '|' signifies a choice of two alternatives. A
'+' signifies that the previous symbol can be present one or more times,
while a '*" means zero or more times.
The following are Alpha-specific tcl routines:
• addMenuItem [-m] [-l <meta-characters>] <menu name> <item name> - Convert
item to menu form and add to specified menu. If '-m' specified, menu
form conversion not done. The '-l' option allows you to use menu meta
characters as text of menu items. If the '-l' option is used, the
<meta-characters> string is interpreted for menu item attributes, and
meta-characters in <item name> are included in the menu item text
literally. For example:
addMenuItem -m -l "/B" "Hello/C"
would appear as the text "Hello/C" in the menu, and have "B" as its
command equivalent.
• alertnote message_string
This command will display message_string in a standard Macintosh alert box.
• ascii (see bindings).
• askyesno prompt
This command will display a Macintosh alert box with promptdisplayed
with the push buttons Yes, No, Cancel. The command will return the
string "yes", "no", or "cancel".
• beep
• bind (see bindings)
• blink <pos> - blink cursor at 'pos'
• breakIntoLines <string> - return 'string' with
carriage returns and spaces inserted to satisfy
'leftFillColumn' and 'fillColumn' variables.
• bringToFront <winName> - Bring named window to front.
• cd [directory]
This command will set the current working directory to "directory". The directory
argument may or may not end with a colon. The working directory is the directory
in which file names that contain no colons (folders) will be located with file related
commands. No argument means Alpha's home directory.
• colors <fore red> <fore green> <fore blue> <back red> <back green> <back blue>
• cp <fromName> <toName> [force]
This command will copy the file fromName and name the new file toName. If
toName includes a path name that is different from the path in fromName, the copy
will be made in a new directory (specified by toName). The copy can be made
across volume (disk drives). The force option indicates that the copy should
overwrite any existing file with the same name as toName. This command copies
both data forks, and the Finder information.
• createTMark <name> <pos> - create a temporary 'mark'
at location 'pos'.
• ctime <time>
This command will return a UNIX time string of the format "Wed Feb 19
22:43:36 1992". The parameter time is in Macintosh seconds, and would be the
result of a now or file mtime command or the like.
• deleteMenuItem [-m] <menu name> <item name> - Convert item to menu form
and delete from specified menu. If '-m' specified, menu form conversion
not done.
• deleteText <pos1> <pos2> - remove text between 'pos1'
and 'pos2'
• displayMode <mode> - Up to four characters of the 'mode' string are
displayed in the status line at the bottom of a window.
• dosc <-c 'sign' | -n appName> <-s string | -f fileName> [-t timeout]
Send a 'misc' 'dosc' AppleEvent. Options are the following:
-c 'sign'
"sign" is a four-letter creator signature of a running application.
-n appName
"appName" is the name of a running application.
-s string
"string" is the text of a script to send to the other app.
-f fileName
"fileName" is the complete or relative pathname of a file the other
application should execute.
-t timeout
"timeout" is the number of ticks Alpha should wait for a response. A
timeout of "0" means wait forever.
-r
Do not wait for reply.
If neither of the '-c' and '-n' options is chosen, the PPC Browser is
used. Either '-s' or '-f' must be chosen. Thus, you can have "Alpha
5.02" and "Alpha 5.02 Copy" sending Apple events to each other, or they
can send events to a remote server such as Apple's ToolServer.
• echo <string> [<string>...] - echo the strings (used
in shells).
• edit <name> [-r] [-m] - Open a file in a new window. '-r' means open
the file read-only. '-m' means omit the function titlebar menu and
present only the marks titlebar menu, which is labeled with the
contents of 'markLabel'.
• get_directory
This command will display a standard Macintosh file dialog and request the user
select a folder. The command will return the selected folder's full path name, or an
empty string if the Cancel button was selected.
• getenv <varname>
This command will return the value of the environment variable varname.
Environment variables are initialized by reading the file •tclenv. The environment
file has the format varname=value as in the following example:
TERM=vt100
TCLINIT=::tcl:TclInit.tcl
TCLDEFAULT=
TEST=TEST
TCLPATH=::tcl:tclsh:tclsrc
• getfile <prompt>
This command will display an SFGetFile() and return the full path name of the
selected file, or an empty string if CANCEL button was selected.
• getfinfo <fileName>
This command will display the standard Macintosh file information in the form:
"'aeQL' 'QUIL' lvbsIdm 02/17/92 23:57:12 02/19/92 22:43:36 0,156 219 0".
The fields are the fdCreator, fdType, fdFlags, flCreationDate, flCreationtime,
flModDate, flModTime, fdLocation.H,V, dataForlLength, rsrcForkLength,
respectively. The fdFlags field uses characters to represent bits:
l/L not locaked/Locked
v/V visible/notVisible
b/B not bundled/Bundled
s/S not system/System
i/I not initialized/Initialized
d/D not desktop/Desktop
m/M not sharable/sharable
• getGeometry - return a TCL list containing the left
edge of the current window, the top, the width, and
height.
• getline <prompt> <default>
This command will display a Macintosh alert box with prompt displayed, a
text edit field with default initially in the field, and with the push
buttons OK, Cancel.. The command will return the text entered into the
text edit field by the user, or an empty string if the user selected the
Cancel button.
• getMainDevice - return a list containing the left, top, right, and
bottom of the rectangle defining the main device.
• getMark - return the current mark.
• getPathName - prompt the user with an SFGetFile dialog and return
complete pathname.
• getPos - return the current insertion point
• getSelect - return the currently selected text, if
any.
• getTMarks - Return a list of temporary marks. Each item of the returned
list is a sublist containing the mark name, the complete pathname of the
mark, and the start and finish of the selection named by the mark. The
following is an example of the result:
{{temp1 External:file.c 1312 1315} {temp2 Internal:it.h 111 111}}
• getText <pos1> <pos2> - return the text between 'pos1'
and 'pos2'.
• glob [-i] [-t <TYPE>] [-c <CRTR>]
The original glob provided by the UNIX version of tcl was not quite
adequate for the more complex Macintosh file system. Issues such as
invisible file handling, Finder type and creator filtering, and space
handling in file names. Release 6 of tcl has dealt with the original
problem with spaces in filenames, but the following options are provided
to deal with additional Macintosh issues.
Anyhow, the new glob now takes several options. They are:
-i This option causes glob to list invisible files also.
-t TYPE This option causes glob to only list file with the
indicated Finder file typeTYPE. This option may be
used with the -c option.
-c CRTR This option causes glob to only list file with the
indicated Finder file creatorCRTR. This option may
be used with the -t option.
Also note that the original glob would skip dot files
(i.e., file names the begin with a period)
in the listing, unless the pattern began with a period.
Tickle extends this concept one step further on the
Macintosh, and skips spot files (i.e., file names that
begin with '•'), unless the pattern starts with a spot.
• goto <pos> - goto the position 'pos'.
• gotoTMark <name> - goto the temporary mark 'name'.
• enableMenuItem <menuName> <item text> <on|off> - Either enable or
disable the menu item of user menu 'menuName' that has text '<item
text>'. Note that unless the menu is not only created, but also already
inserted, this command has no effect.
• icon [-f <winName>] [-c|-o|-t] [-g <h> <v>] - Having to do w/
iconifying windows. '-c' means close (iconify) window, '-o' open, '-t'
toggle open/close, and '-g' moves the icon to horizontal position <h>
and vertical position 'v'. Options are executed as they are parsed, so
the '-f' option, if present, should always be first.
• insertMenu <name> - insert the previously created user menu 'name' into
the menuBar.
• insertText [-w <win name>] <text> [<text>]... - Insert 'text' at the current
insertion point.
• launch -f <name> - launch the named app into the background. Note that
for some yet unexplained reason, some applications (MicroSoft Word)
won't launch completely in the background. 'launch'ing such
applications won't insert the application into any system menu that
specifies running applications (although "About the Finder..." will
list it. The only way to get to such an app is through Alpha's
'switchTo', after which the application will finish launching. The '-f'
option gets around this by launching the application in the foreground
instead.
• lineStart <pos> - return the position of the start of
the line 'pos' is on.
• listpick [-p <prompt>] <list>
This command will display a dialog with the list displayed in a List Manager list. If
the user presses the Cancel button, an empty string is returned. If the user selects
the Open button, or double clicks an item in the list, that item will be returned.
• lookAt [-w <name>] <pos> - return the 'pos'th character of the
current file, or the file named by <name> if the '-w' option is specified.
• markMenuItem <menuName> <item text> <on|off> - Either mark or unmark
the menu item of user menu 'menuName' that has text '<item text>'.
Note that unless the menu is not only created, but also already
inserted, this command has no effect.
• matchIt <brace char> <pos> - Return pos of matching brace. Recognizes
parenthesis, square brackets, and curly braces.
• maxPos - returns the number of characters in the front
window.
• menu [-n <name>] [-m] [-p <procname>] <list of menu items> - Defines a
new menu named 'name' (if provided w/ '-n' option). The menu is not yet
inserted into the menubar. The menu commands may be nested for
heirarchical menus, see 'AlphaBits.tcl' for examples. Alpha massages the
function names to make them look better in the menus.
'-n <name>' Name the menu. Not necessary for submenus.
'-m' No menu form. If not supplied, each menu item is split into
words at each capitalized letter.
'-p <name>' The tcl proc named by 'name' is called w/ the menu item's
contents as it's single argument when the item is chosen. If the
proc returns "normal" as its result, the menu item is executed as
if no proc had been specified.
• message <string> - prints 'string' on the status line.
• mkdir <name> - creates a directory (folder) named
'name' in the current directory.
• moveWin [win name] <left> <top> - moves current or specified window.
• mtime <time> [long|short|abbrev]
Returns a date and time string using the Macintosh International Utilities. The
long/short/abbrev specification corresponds to the date. These are the following
formats:
short 3/16/92 9:20:46 PM
abbrev Mon, Mar 16, 1992 9:20:49 PM
long Monday, March 16, 1992 9:20:43 PM
• mv <fromName> <toName> [force]
This command will move the file fromName to toName. If toName includes a path
name that is different from the path in fromName, the file will be moved into a new
directory (specified by toName). The move can not be made across volume (disk
drives). The force option indicates that the move should overwrite any existing file
with the same name as toName.
• nextLineStart <pos> - return the position of the start
of the next line after position 'pos'.
• now
Returns the current time as Macintosh seconds. This is the number of seconds that
have elapsed since Midnight Jan 1, 1904. Appropriate for input to ctime.
• posToRowCol <pos> - converts from absolute position to row, col.
• prompt <prompt> <default> [<name> <menu item>...] - prompt dialog to
the user with a prompt string and a default value. The prompt dialog can
optionally include a popup menu specified by 'name' and the succeeding
strings. Selection of the popup menu items inserts the item text into the
editable dialog item. 'Prompt' returns the value of the editable item.
If the 'Cancel' button is selected, the tcl returns an error and your
script will be stopped unless you execute the command from 'catch'.
• putenv <varname> <value>
This command will set the environment variable varname to value.
• putfile <prompt> <original>
This command will display an SFPutFile() and return the full path name of the
selected file, or an empty string if CANCEL button was selected. Original is the
default name displayed for the user.
• pwd
This command will return the current working directory.
• removeMenu <name> - remove menu 'name' from menubar.
• removeTMark <name> - remove temporary mark.
• replaceText <pos1> <pos2> [text]+ - replaces the text
between 'pos1' and 'pos2' with 'text', where 'text' can be any number
of arguments.
• rm <fileName>
This command will delete the file fileName.
• rowColToPos <row> <col> - converts to abosolute position.
• search [-f <num>] [-r <num] [-i <num>] [-m <num] [-n] [-l <limit>] <pattern> <pos> -
Searches for 'pattern' from position 'pos'. The '-f', '-r', '-i', and
'-m' options allow the 'forward', 'regExpr', 'ignoreCase', and
'matchWord' internal variables to be set. The '-l' option allows a search
limit to be set. The search fails if the a match is not found totally
contained between 'pos' and 'limit'. The '-n' option specifies that a
failed search still returns TCL_OK. However, the result of the call is
then just an empty string. If the search succeeds, a list of two
positions will be returned. The first is the starting position of the
match, the second is one past the last character.
• select <pos1> <pos2> - selects the text between 'pos1'
and 'pos2'.
• selEnd - returns the end of the hilited selection, or
the current insertion point if no text is selected.
• sendToBack <winName> - Sent named window to back.
• setfinfo <fileName> [-a flags] [-c fdCreator] [-t fdTypes]
This command will set the standard Macintosh file information. The flags setting
must be of the same format as displayed by the getfinfo flag.
• shadowVar <name> - Associates a Tcl variable with an Alpha variable of
the same name. Writes to the Tcl variable automatically are copied to
the Alpha variable.
• sizeWin [win name] <width> <height> - sets size of current or specified window.
• substituteVars <string> - Takes a single string and
substitutes for all variables inside it, regardless of
depth. Unfortunately, you currently need to make 'global var'
declarations in the proc you call this for each 'var' that might need
to be substituted in the string (see proc.tcl for examples).
• switchTo <appName> - Switches to application 'appName'.
• tclResult - displays a dialog showing the result of
the last TCL evaluation.
• ticks
Returns the current TickCount. Ticks are 60ths of a seconds. TickCount is the
number of ticks since the Macintosh was started. The command:
puts stdout [expr "[ticks] / 60"]
will print the number of seconds since the Macintosh was booted.
• traceFunc on <funcName> <winName> Trace 'funcName', send output to
'winName'.
traceFunc off Turn function tracing off.
traceFunc status Display current tracing status.
• watchCursor - turns the cursor into a a watch cursor.
• winNames [-f] - return a TCL list of all open windows. If '-f' option
specified, complete pathnames are returned.
• wrapText
• xtclcmd [-f filename] <cmdname> [argument_list]...
This command will load the external command cmdname and pass it the argument
list [ cmdname argument_list... ]. External command are code resources of type
XTCL. They may be located in the resource fork of the tickle application, or they
may be located in a file named XTCL File in the same directory as the tickle
application. If the optional -f filename is included, the external command will first
be loaded from filename before the other two files.
See the appendix for a detailed description of the external tcl command interface.
See the accompanying sources for an example of writing an XTCL.